package cn.mcartoon.serviceImpl;
import cn.mcartoon.mapper.MmCartoonThemeRelMapper;
import cn.mcartoon.pojo.MmCartoonThemeRel;
import cn.mcartoon.service.MmCartoonThemeRelService;
import cn.mcartoon.dto.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;
@Service
public class MmCartoonThemeRelServiceImpl implements MmCartoonThemeRelService {

    @Autowired
    private MmCartoonThemeRelMapper mmCartoonThemeRelMapper;

    public MmCartoonThemeRel getMmCartoonThemeRelById(Long id){
        return mmCartoonThemeRelMapper.getMmCartoonThemeRelById(id);
    }

    public List<MmCartoonThemeRel>	getMmCartoonThemeRelListByMap(Map<String,Object> param){
        return mmCartoonThemeRelMapper.getMmCartoonThemeRelListByMap(param);
    }

    public Integer getMmCartoonThemeRelCountByMap(Map<String,Object> param){
        return mmCartoonThemeRelMapper.getMmCartoonThemeRelCountByMap(param);
    }

    public Integer insertMmCartoonThemeRel(MmCartoonThemeRel mmCartoonThemeRel){
            return mmCartoonThemeRelMapper.insertMmCartoonThemeRel(mmCartoonThemeRel);
    }

    public Integer updateMmCartoonThemeRel(MmCartoonThemeRel mmCartoonThemeRel){
        return mmCartoonThemeRelMapper.updateMmCartoonThemeRel(mmCartoonThemeRel);
    }

    public Integer deleteMmCartoonThemeRelById(Long id){
        return mmCartoonThemeRelMapper.deleteMmCartoonThemeRelById(id);
    }

    public Integer batchDeleteMmCartoonThemeRel(String ids){
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return mmCartoonThemeRelMapper.batchDeleteMmCartoonThemeRel(param);
    }

    public Page<MmCartoonThemeRel> queryMmCartoonThemeRelPageByMap(Map<String,Object> param,Integer pageNo,Integer pageSize){
        Integer total = mmCartoonThemeRelMapper.getMmCartoonThemeRelCountByMap(param);
        Page page = new Page(pageNo, pageSize, total);
        param.put("beginPos", page.getBeginPos());
        param.put("pageSize", page.getPageSize());
        List<MmCartoonThemeRel> mmCartoonThemeRelList = mmCartoonThemeRelMapper.getMmCartoonThemeRelListByMap(param);
        page.setList(mmCartoonThemeRelList);
        return page;
     }


}
